$(function() {
	var start=0,page=1,showNumber=6;
	var isload = true;
	var contextPath = $("#contextPath").val();
	var vipRecommended_head = $("#vipRecommended_head");
	var vipGoodsList = $("#vipGoodsList");
	dataInit();

	var upvip = $("#upvip");
	var hidden = $("#hidden");
	if(hidden.val() > 0){
		upvip.text("VIP升级")
	}
dropload.scroll(function(t){
	if(t<5&&isload){
		$(".lodingStyle").show();
		isload = false;
		dataInit();
	}

});
	
function dataInit(){
	var param;
	var is_points_buy = $("#is_points_buy").val();
	if(is_points_buy.length<=0){
		 param = {start:start,showNumber:showNumber}
	}else{
		param = {start:start,showNumber:showNumber,"params['is_points_buy']":is_points_buy}
	}
	$.ajax({
		url:"vip/getVipRecommended",
		type:"post",
		async:true,
		data:param,
		dataType:"json",
		success : function(data, textStatus) {
			$(".lodingStyle").hide();
			var state = data.result.state;
			if(state == 1){
				$.each(data.rVipHeadList,function(i,v){
					vipRecommended_head.append('<div class="swiper-slide"><a href="'+ v.hrefUrl +'"><img src="'+ v.picUrl +'"  alt=""></a></div>');
				});
				
				$.each(data.rVipGoodsList,function(i,v){
					if(v.is_sales == "00"){
						if(v.thumb == ""){
							vipGoodsList.append('<li class="popular__item""><i class="vip_mark"></i><a href="'+ contextPath +'/goods/detailPage?goodsId=' + v.id + '"><span class="commodity__img"><img src="'+contextPath+'/static/images/icon_default_02.jpg"></span><p class="commodity__txt">' + v.title + '</p></a><div class="commodity__live tj"><span class="dib vm commodity__live_price">&yen;'+ v.real_price + '</span><span class="dib vm commodity__live_marketprice" style="display:none">市价'+ v.price + '</span><span class="dib vm commodity__live_buy icon_car"></span></div></div>');
						}else{
							vipGoodsList.append('<li class="popular__item""><i class="vip_mark"></i><a href="'+ contextPath +'/goods/detailPage?goodsId=' + v.id + '"><span class="commodity__img"><img src="'+ v.thumb +'" onerror="this.src=\''+contextPath+'/static/images/icon_default_02.jpg\'"></span><p class="commodity__txt">' + v.title + '</p></a><div class="commodity__live tj"><span class="dib vm commodity__live_price">&yen;'+ v.real_price + '</span><span class="dib vm commodity__live_marketprice" style="display:none">市价'+ v.price + '</span><span class="dib vm commodity__live_buy icon_car"></span></div></div>');
						}
					}else {
						if(v.thumb == ""){
							vipGoodsList.append('<li class="popular__item""><i class="vip_mark"></i><a href="'+ contextPath +'/goods/detailPage?goodsId=' + v.id + '"><span class="commodity__img"><img src="'+contextPath+'/static/images/icon_default_02.jpg"></span><p class="commodity__txt">' + v.title + '</p></a><div class="commodity__live tj"><span class="dib vm commodity__live_price">&yen;'+ v.real_price + '</span><span class="dib vm commodity__live_marketprice">市价'+ v.price + '</span><span class="dib vm commodity__live_buy icon_car"></span></div></div>');
						}else{
							vipGoodsList.append('<li class="popular__item""><i class="vip_mark"></i><a href="'+ contextPath +'/goods/detailPage?goodsId=' + v.id + '"><span class="commodity__img"><img src="'+ v.thumb +'" onerror="this.src=\''+contextPath+'/static/images/icon_default_02.jpg\'"></span><p class="commodity__txt">' + v.title + '</p></a><div class="commodity__live tj"><span class="dib vm commodity__live_price">&yen;'+ v.real_price + '</span><span class="dib vm commodity__live_marketprice">市价'+ v.price + '</span><span class="dib vm commodity__live_buy icon_car"></span></div></div>');
						}
					}
				});
				start=(page--)*showNumber;
				page++;
				if(data.rVipHeadList.length == showNumber){
					isload = true;	
				}
			}	
		},
		error : function(XMLHttpRequest, textStatus, errorThrown){
			layer.open({
			    content:textStatus,
			    time: 2
			});
		}
	});		
}

$('#btn_permissions').on('click',function(){
	  var pageii = layer.open({
		    type: 1,
		    content: '<div style="padding:.5rem">'+
		    '<p>“畏则不敢肆而德以成，无畏则从其所欲而及于祸。”官有所畏，业有所成。腐败总是发生在掌权者失去敬畏之心的地方。没有敬畏，权力就不受约束；就会出现滥权、专权、弄权。习近平多次强调，“领导干部要心存敬畏”。心存敬畏，律己、慎言、慎行，权力才不会用偏，行为才不会越界。每一位领导干部都要把“敬畏”二字根植于心间。习近平在庆祝中国共产党成立95周年大会上指出：“各级领导干部要牢固树立正确权力观，保持高尚精神追求，敬畏人民、敬畏组织、敬畏法纪，做到公正用权、依法用权、为民用权、廉洁用权，永葆共产党人拒腐蚀、永不沾的政治本色。”请随“学习中国”小编一起学习。</p>'+
		    '<div class="tc" style="padding-top:1rem"><a id="btn_close" class="ui_btn ui_btn_primary db tc" href="javascript:;">返回</a></div>'+
		    '</div>',
		    style: 'position:fixed; left:0; top:0; width:100%; height:100%; border:none;',
		    success:function(lay,index){
		    	console.log(lay,index)
		    $('#btn_close').on('click',function(){
		    	layer.close(pageii)
		    });
		    	
		    }
		});
});

});